package com.hongye.house.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.hongye.house.entity.TypeHomeEntity;
import com.hongye.house.service.TypeHomeService;
import com.hongye.common.utils.PageUtils;
import com.hongye.common.utils.R;



/**
 * 房产类型表
 *
 * @author lins
 * @email 695565697@qq.com
 * @date 2021-10-14 13:32:23
 */
@RestController
@RequestMapping("house/typehome")
public class TypeHomeController {
    @Autowired
    private TypeHomeService typeHomeService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = typeHomeService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{typeId}")
    public R info(@PathVariable("typeId") Integer typeId){
		TypeHomeEntity typeHome = typeHomeService.getById(typeId);

        return R.ok().put("typeHome", typeHome);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody TypeHomeEntity typeHome){
		typeHomeService.save(typeHome);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody TypeHomeEntity typeHome){
		typeHomeService.updateById(typeHome);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] typeIds){
		typeHomeService.removeByIds(Arrays.asList(typeIds));

        return R.ok();
    }

}
